home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / solaris2 / jdk / src / java / awt / test / choicete.jav < prev    next >
Encoding:
Text File  |  1995-10-30  |  1.7 KB  |  66 lines

  1. /*
  2.  * @(#)ChoiceTest.java    1.1 95/08/06 Arthur van Hoff
  3.  *
  4.  * Copyright (c) 1995 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. import java.awt.*;
  21.  
  22. /**
  23.  * A test of Choice components.
  24.  */
  25. public class ChoiceTest extends Frame {
  26.     Choice c1;
  27.     Choice c2;
  28.  
  29.     public ChoiceTest() {
  30.     super("ChoiceTest");
  31.     c1 = new Choice();
  32.     c1.addItem("one");
  33.     c1.addItem("two");
  34.     c1.addItem("three");
  35.     c1.addItem("four");
  36.     add("North", c1);
  37.  
  38.     c2 = new Choice();
  39.     c2.addItem("een");
  40.     c2.addItem("twee");
  41.     c2.addItem("drie");
  42.     c2.addItem("vier");
  43.     add("Center", c2);
  44.  
  45.     add("South", new Button("print"));
  46.     move(200, 100);
  47.     pack();
  48.     show();
  49.     }
  50.  
  51.     public boolean action(Event evt, Object arg) {
  52.     if ("print".equals(arg)) {
  53.         System.out.println("-- selected items --");
  54.         System.out.println(c1.getSelectedItem());
  55.         System.out.println(c2.getSelectedItem());
  56.         return true;
  57.     }
  58.     System.out.println(evt.toString());
  59.     return false;
  60.     }
  61.  
  62.     public static void main(String args[]) {
  63.     new ChoiceTest();
  64.     }
  65. }
  66.